Skip to content

fix infinite recursion in divmoddi4 / mulodi4 #146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 7, 2017
Merged

fix infinite recursion in divmoddi4 / mulodi4 #146

merged 1 commit into from
Mar 7, 2017

Conversation

japaric
Copy link
Member

@japaric japaric commented Mar 6, 2017

on ARMv7-M processors, divmoddi4 was calling mulodi4 and mulodi4 was calling
divmoddi4 leading to infinite recursion. This commit breaks the cycle by using
wrapping multiplication in divmoddi4.

fixes #145

r? @alexcrichton

on ARMv7-M processors, divmoddi4 was calling mulodi4 and mulodi4 was calling
divmoddi4 leading to infinite recursion. This commit breaks the cycle by using
wrapping multiplication in divmoddi4.

fixes #145
@alexcrichton
Copy link
Member

@bors: r+

Out of curiosity, do you think it'd be feasible to CI against this? It seems like a common failure mode...

@bors
Copy link
Contributor

bors commented Mar 6, 2017

📌 Commit 644a1c9 has been approved by alexcrichton

@bors
Copy link
Contributor

bors commented Mar 6, 2017

⌛ Testing commit 644a1c9 with merge 8bd620f...

bors added a commit that referenced this pull request Mar 6, 2017
fix infinite recursion in divmoddi4 / mulodi4

on ARMv7-M processors, divmoddi4 was calling mulodi4 and mulodi4 was calling
divmoddi4 leading to infinite recursion. This commit breaks the cycle by using
wrapping multiplication in divmoddi4.

fixes #145

r? @alexcrichton
@japaric
Copy link
Member Author

japaric commented Mar 6, 2017

Out of curiosity, do you think it'd be feasible to CI against this? It seems like a common failure mode...

We would have to test the intrinsics on no_std targets like thumbv7m-none-eabi to catch these. That's possible with utest but quickcheck doesn't compile on no_std so we would have to add unit tests that don't depend on quickcheck specifically to test these targets. See #144.

Ideally, I'd like a much simpler test system. One that doesn't depend on compiling libgcc or compiler-rt or even quickcheck. Basically have something like this:

#[test]
fn muldi3() {
    assert_eq!(__muldi3(1, 1), 1);
    assert_eq!(__muldi3(1, 2), 2);
    assert_eq!(__muldi3(2, 3), 6);
    // ...
}

Where the assertions are randomly generated before we run the test suite. compiler-rt test suite is like this but has fixed test cases rather than randomly generated ones.

@alexcrichton
Copy link
Member

Could we perhaps have a separate project which is compatible with utest, not using quickcheck? (and then use both on CI)

@japaric
Copy link
Member Author

japaric commented Mar 6, 2017

Ideally, I'd like a much simpler test system.

I got a proof of concept for this system here. I have tested that it works for the x86_64-unknown-linux-gnu, armv7-unknown-linux-gnueabihf and thumbv7m-linux-eabi targets. I have only tested muldi3 and mulodi4 so far but apparently I've already found another bug in mulodi4:

thread 'mulodi4' panicked at 'attempt to subtract with overflow', /cargo/git/checkouts/compiler-builtins-ec094dc45a0179c8/644a1c9/src/int/sdiv.rs:13

@bors
Copy link
Contributor

bors commented Mar 7, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: alexcrichton
Pushing 8bd620f to master...

@bors bors merged commit 644a1c9 into master Mar 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ARMv7-M: infinite recursion with __divmoddi4 / __mulodi4
3 participants